<template>
  <div class="main">
    <!-- 搜索框 -->
    <div class="search">
      <input
        type="text"
        placeholder="输入联系方式查询"
        v-model="searchKey"
        @keyup.enter="search"
      />
      <img src="../assets/images/serach.png" alt="" srcset="" @click="search" />
    </div>
    <div class="search-wrap">
      <div class="tip" v-if="isShow">请输入联系方式查询人员信息</div>
      <div class="search-result" v-else>
        <img class="bg" :src="memberData.image" alt="" />
        <div class="title">人员信息</div>
        <div class="cont">
          <div class="item">
            <div class="head-portrait">
              <img :src="memberData.image" alt="" />
            </div>
            <div class="line"></div>
            <div class="info">
              <div class="lf">
                <div class="row">
                  <span>姓名：</span>
                  {{memberData.name}}
                </div>
                <div class="row">
                  <span>别名：</span>
                  {{memberData.nickname}}
                </div>
                <div class="row">
                  <span>民族：</span>
                  {{memberData.nationality}}
                </div>
                <div class="row">
                  <span>部门：</span>
                  {{memberData.department}}
                </div>
                <div class="row">
                  <span>联系方式：</span>
                  {{memberData.phone}}
                </div>
              </div>
              <div class="rt">
                <div class="row">
                  <span>籍贯：</span>
                  {{memberData.from}}
                </div>
                <div class="row">
                  <span>面貌：</span>
                  {{memberData.role}}
                </div>
                <div class="row">
                  <span>学历：</span>
                  {{memberData.education}}
                </div>
                <div class="row">
                  <span>入职时间：</span>
                  {{memberData.join_time}}
                </div>
                <div class="row">
                  <span>离职时间：</span>
                  <template v-if="memberData.status == 1">在职</template>
                  <template v-else>{{memberData.left_time}}</template>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      isShow: true,
      searchKey: '', // 搜索词
      memberData: []
    }
  },
  methods: {
    search () {
      if (this.searchKey.trim().length <= 0) {
        this.$message.error('搜索词不能为空！')
      } else {
        this.$http.getMember(this.searchKey).then((res) => {
          if (res.data.code === 0) {
            if (res.data.data.length > 0) {
              this.isShow = false
              this.memberData = res.data.data[0]
            } else {
              this.$message.error('没搜索到你想要的内容！')
              this.isShow = true
            }
          } else {
            this.$message.error('请求失败，请重试！')
          }
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.search {
  width: 636px;
  height: 44px;
  background: #ffffff;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  align-items: center;
  margin: 0 auto;
  margin-top: 28px;
  margin-bottom: 40px;
  input {
    width: 582px;
    height: 44px;
    border: none;
    outline: none;
    padding: 0 40px;
    font-size: 20px;
  }
  input::-webkit-input-placeholder {
    color: #cccccc;
    font-size: 20px;
  }
  input::-moz-placeholder {
    /* Mozilla Firefox 19+ */
    color: #cccccc;
    font-size: 20px;
  }
  input:-moz-placeholder {
    /* Mozilla Firefox 4 to 18 */
    color: #cccccc;
    font-size: 20px;
  }
  input:-ms-input-placeholder {
    /* Internet Explorer 10-11 */
    color: #cccccc;
    font-size: 20px;
  }
  img {
    width: 24px;
    height: 24px;
    cursor: pointer;
  }
}
.search-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 80px;
  .tip {
    font-size: 36px;
    font-family: PingFang SC;
    font-weight: bold;
    color: #cccccc;
    text-align: center;
    padding-top: 205px;
    padding-bottom: 272px;
  }
  .search-result {
    background-color: #fff;
    padding: 40px 0;
    border-radius: 10px;
    box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
    background-repeat: no-repeat;
    background-position: right top;
    background-size: 330px 406px;
    // filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.30;
    position: relative;
    z-index: 10;
    overflow: hidden;
    .bg {
      width: 330px;
      height: 415px;
      position: absolute;
      right: 0;
      top: 0;
      z-index: 1;
      filter: alpha(opacity=50);
      -moz-opacity: 0.5;
      opacity: 0.5;
    }
    .title {
      font-size: 48px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #333333;
      text-align: center;
      padding-bottom: 40px;
    }
    .cont {
      position: relative;
      z-index: 10;
      .item {
        max-width: 1200px;
        margin: 0 auto;
        display: flex;
        .head-portrait {
          width: 115px;
          height: 160px;
          margin-left: 130px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .line {
          width: 0px;
          height: 220px;
          border: 1px solid #536786;
          opacity: 0.2;
          margin: 0 60px;
        }
        .info {
          display: flex;
          .lf {
            margin-right: 100px;
          }
          .lf .row,
          .rt .row {
            font-size: 20px;
            font-family: PingFang SC;
            font-weight: 400;
            line-height: 40px;
            color: #333333;
            span {
              color: #999999;
            }
          }
        }
      }
    }
  }
}
</style>
